/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.service;

import java.sql.SQLException;

import cn.itlaobing.dao.UserDao;
import cn.itlaobing.exception.MyBusinessException;
import cn.itlaobing.model.UserModel;

/** 
 * ClassName: UserService <br/> 
 * Function: TODO 功能描述 <br/> 
 * date: 2017年11月1日 上午11:08:39 <br/> 
 * 
 * @author lhb 
 * @version  
 * @since JDK 1.8 
 */
public class UserService {
	private UserDao ud=new UserDao();

	public int modifyLastDate(int id)throws MyBusinessException{
		int r=0;
		try {
			r=ud.modifyDate(id);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new MyBusinessException(e.getMessage());
		} catch (SQLException e) {
			e.printStackTrace();
			throw new MyBusinessException(e.getMessage());
		}
		return r;
	}
	//用户登录
	public UserModel login(String name,String pwd)throws MyBusinessException {
		UserModel userModel=null;
		try {
			userModel=ud.login(name, pwd);
			if (userModel!=null){
				ud.modifyDate(userModel.getUserid());
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new MyBusinessException(e.getMessage());
		} catch (SQLException e) {
			e.printStackTrace();
			throw new MyBusinessException(e.getMessage());
		}
		return userModel;
	}
	
}
